<? 
$this->load->library('form_validation');

function error_class($form_error) {
	if (($form_error)!="") {
		echo "error";
	}
}

function error_msg($msg, $form_error) {
	if (($form_error)!="") {
		echo '<p class="error-msg">'.$msg.'</p>';
	};
}

?>

	<script src="/js/jquery-1.10.1.min.js"></script>
	<script src="/js/jquery.cityselect.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#administrative").citySelect({
				nodata:"hidden",
				required:false,
				prov:"<? echo set_value('prov'); ?>", 
				city:"<? echo set_value('city'); ?>", 
				dist:"<? echo set_value('dist'); ?>"
			});
		});
	</script>
	<? echo $script_tooltip ?>
</head>
<body>
<div id="container">
<h1 class="header">葡萄园基本信息</h1>
<div id="body">
	<div name="error" style="display: none;"><?php echo validation_errors(); ?></div>
	<? 
		$form_attributes = array('class' => 'pure-form');
		echo form_open('register', $form_attributes); 
	?>

		<div class="q-div <? error_class(form_error('station')) ?>" style="" name="station">
			<div class="q-title">请选择所属试验站:</div>
			<? echo error_msg("请作出选择",form_error('station')) ?>
			<select class="q-select" name="station">
				<?php
				$this->load->model('options_model');
				
				$select_data['options'] = $this->options_model->get_select_options('mgt_experiment_stations');
				$select_data['select_name'] = 'station';
				$select_data['set_value'] = set_value('station');	// 验证失败后填回的值
				
				$data['select_content'] = $this->load->view('qtypes/options', $select_data);
				?>
			</select>
		</div>
		<div class="q-div <? error_class(form_error('prov').form_error('city').
						form_error('dist').form_error('address')) ?>" 
						style="" name="administrative">
			<div class="q-title">请填入您葡萄园的通讯地址</div>
			<div id="administrative" class="sub-q">
				<? echo error_msg("请选择省（自治区、直辖市或特别行政区）",form_error('prov'));
					echo error_msg("请选择市（区、直辖县或自治州）",form_error('city'));
					echo error_msg("请选择区（县、县级市或自治县）",form_error('dist')) ?>
				<table border="0">
					<tr>
						<td width="70px">省 市 区：</td>
					<td>
						<select class="prov q-select" name="prov"></select>
						<select class="city q-select" name="city" style="display: none;"></select>
						<select class="dist q-select" name="dist" style="display: none;">
							<option value="default">请选择</option>
						</select>
					</td>
					</tr>
				</table>
			</div>
			<div class="sub-q">
				<? echo error_msg("请填入您的详细地址",form_error('address')) ?>
				<table border="0">
				<tr>
					<td width="70px">详细地址：</td>
					<td><? $input_data_address = array(
											'name' => 'address',
											'value' => trim(set_value('address')),
											'size' => '30',
											'class' => 'q-text',
											'id' => 'address_input');
							echo form_input($input_data_address); ?>
					</td>
				</tr>
				</table>
			</div>
		</div>
		<div class="q-div <? error_class(form_error('contact')) ?>" style="" name="contact">
			<div class="q-title">请填入联系人姓名</div>
			<? echo error_msg("请填入您的姓名",form_error('contact')) ?>
			<? $input_data_contact = array(
								'name' => 'contact',
								'value' => trim(set_value('contact')),
								'size' => '10',
								'class' => 'q-text',
								'id' => 'contact_input');
				echo form_input($input_data_contact); ?>
		</div>
		<div class="q-div <? error_class(form_error('telephone')) ?>" style="" name="telephone">
			<div class="q-title">联系人手机号码</div>
			<? echo form_error('telephone', '<p class="error-msg">', '</p>') ?>
			<? $input_data_telephone = array(
								'name' => 'telephone',
								'value' => trim(set_value('telephone')),
								'size' => '15',
								'class' => 'q-text',
								'id' => 'telephone_input',
								'autocomplete' => 'off');
				echo form_input($input_data_telephone); ?>
		</div>
		<div class="next-page-button" style="padding:10px;text-align:center;">
			<button type="submit" class="pure-button pure-button-primary">下一页</button>
		</div>

		
	</form>
	<!-- 气泡提示 -->
	<div class="">
		<div class="jfk-bubble" name="bubble-address_input">
			<div class="jfk-bubble-arrow"></div>
			<p>在这里输入您葡萄园所在的地址，如</p>
		</div>
		<div class="jfk-bubble" name="bubble-contact_input">
			<div class="jfk-bubble-arrow"></div>
			<p>在这里填入您的姓名，您就成为了这个葡萄园的主要联系人</p>
		</div>
		<div class="jfk-bubble" name="bubble-telephone_input">
			<div class="jfk-bubble-arrow"></div>
			<p>输入您可使用的手机号码，将作为您登陆时的凭证</p>
		</div>
	</div>
</div>
